package com.lesso.lzh.sunflower.domain.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.lesso.lzh.sunflower.domain.repository.EmployeeAttendanceRuleRepository;
import com.lesso.lzh.sunflower.infra.assembler.EmployeeAttendanceRuleAssembler;
import com.lesso.lzh.sunflower.model.EmployeeAttendanceRule;
import com.lesso.lzh.sunflower.pojo.dto.EmployeeAttendanceRuleDTO;
import com.lesso.lzh.sunflower.pojo.dto.EmployeeAttendanceRuleQueryDTO;
import com.lesso.lzh.sunflower.pojo.vo.EmployeeAttendanceRuleVO;
import org.springframework.stereotype.Service;

/**
 * EmployeeAttendanceRuleDomainService
 *
 * @author zqz
 * @since 2025-07-04
 */
@Service
public class EmployeeAttendanceRuleDomainService {

    private final EmployeeAttendanceRuleRepository employeeAttendanceRuleRepository;

    public EmployeeAttendanceRuleDomainService(EmployeeAttendanceRuleRepository employeeAttendanceRuleRepository) {
        this.employeeAttendanceRuleRepository = employeeAttendanceRuleRepository;
    }

    public Long save(EmployeeAttendanceRuleDTO dto) {
        return employeeAttendanceRuleRepository.save(EmployeeAttendanceRuleAssembler.INSTANCE.dtoToEntity(dto));
    }

    public Page<EmployeeAttendanceRuleVO> page(EmployeeAttendanceRuleQueryDTO dto) {
        return employeeAttendanceRuleRepository.getPageList(dto);
    }

    public Page<EmployeeAttendanceRuleVO> customPage(EmployeeAttendanceRuleQueryDTO dto) {
        return employeeAttendanceRuleRepository.getCustomPageList(dto);
    }

    public void deleteById(Long id) {
        employeeAttendanceRuleRepository.removeById(id);
    }

    public EmployeeAttendanceRule selectById(Long id) {
        return employeeAttendanceRuleRepository.selectById(id);
    }

    public void update(EmployeeAttendanceRule rule) {
        employeeAttendanceRuleRepository.update(rule);
    }
}